package cn.relx.basic.controller;

import cn.relx.basic.service.LoginService;
import cn.relx.basic.util.AjaxResult;
import cn.relx.basic.vo.LoginVo;
import cn.relx.basic.vo.WechatVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping("/account")
    public AjaxResult account(@RequestBody LoginVo loginVo){
        HashMap<String,Object> map = loginService.account(loginVo);
        return AjaxResult.me().success().setResultObj(map);
    }
    @PostMapping("/wechat")
    public AjaxResult weChat(@RequestBody WechatVo wechatVo){
        return loginService.weChat(wechatVo);
    }
    @PostMapping("/wechat/binder")
    public AjaxResult binder(@RequestBody WechatVo wechatVo){
        HashMap<String,Object> map = loginService.binder(wechatVo);
        return AjaxResult.me().success().setResultObj(map);
    }
}
